package cn.iocoder.yudao.module.api.member.task.enums;

import cn.iocoder.yudao.framework.business.basic.enums.EnumValuable;
import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

/**
 * 任务记录状态
 *
 * @author 山野羡民
 */
@RequiredArgsConstructor
@Getter
public enum TaskStatusEnum implements EnumValuable {

    PENDING(0, "未开始"),
    DOING(1, "进行中"),
    DONE(2, "已完成"),
    EXPIRED(3, "已结束"),
    ;

    @EnumValue
    private final Integer value;
    private final String name;

    @Override
    public String toString() {
        return new ViewObject(value, name).toString();
    }

    public static TaskStatusEnum valueOf(Integer value) {
        for (TaskStatusEnum item : values()) {
            if (item.getValue().equals(value)) {
                return item;
            }
        }
        return PENDING;
    }
}
